NAG Logo
Numerical Algorithms Group

Using the NAG C Library Windows DLLs

The information on this page is applicable to Mark 8 of NAG C Library DLLs.

Accessing the Library from the Command Line

In the following, driver.c respresents the name of your application program and install dir is the folder where the NAG C Library DLLs product is installed.

  • Microsoft Visual C++
      cl /MD /I"install dir\include" driver.c
          "install dir\lib\CLDLL084Z_nag.lib"
    
    (on one continuous line).

    The "/MD" option should be used to specify linking with MSVCRT.LIB.

    Alternatively, if you wish to link to the version of the NAG C Library that uses the Intel® Math Kernel Library 8.0 for Windows (MKL) which is included in this product, you should compile your program in the following manner:

      cl /MD /I"install dir\include" driver.c
          "install dir\lib\CLDLL084Z_mkl.lib"
    

    If the folder containing the import libraries has been added to the LIB environment variable and the include folder has been added to the INCLUDE environment variable, these commands may be simplified to

      cl /MD driver.c CLDLL084Z_nag.lib
    
    and
      cl /MD driver.c CLDLL084Z_mkl.lib
    
    respectively.

    Tested with VC++ 7 (Visual Studio .NET 2003) and VC++ 8 (Visual Studio 2005).

  • Intel C++
      icl /MD /I"install dir\include" driver.c
          "install dir\lib\CLDLL084Z_nag.lib"
    
    or, if the LIB and INCLUDE environment variables have set appropriately,
      icl /MD driver.c CLDLL084Z_nag.lib
    

    Substitute CLDLL084Z_mkl.lib to use MKL.

    Tested with Intel C++ 8.1.

  • Borland C++

    Borland import libraries (CLDLL084Z_nag_bc.lib and CLDLL084Z_mkl_bc.lib) are supplied with this implementation and may be found in the install dir\lib folder.

    You may compile and link your C application program to the NAG C Library DLL on the command line in the following manner:

      bcc32 /I"install dir\include" driver.c 
          "install dir\lib\CLDLL084Z_nag_bc.lib"
    

    Alternatively you may add the location of the NAG header files and the folder containing the import libraries to the -I and -L entries respectively in the configuration file bcc32.cfg. For more details please see the compiler documentation. If you have amended the configuration file then you may simply type:

      bcc32 driver.c CLDLL084Z_nag_bc.lib
    

    Substitute CLDLL084Z_mkl_bc.lib to use MKL. Occasionally, when using the MKL-based DLL, the handling of floating-point exceptions may cause the program to terminate abnormally; if you experience such problems, it is recommended that you use the self-contained NAG DLL instead.

    Tested with Borland C++ (bcc32) 5.8 (from Borland Developer Studio 2006 / Borland C++ Builder Preview Version 10.0).

  • gcc

    To compile with gcc in a Windows command prompt window:

      gcc -mno-cygwin -I "install dir\include" driver.c
          "install dir\lib\CLDLL084Z_nag.lib" -o driver.exe
    
    To compile with gcc in a Cygwin xterm window:
      gcc -mno-cygwin -I "install dir/include" driver.c
          "install dir/lib/CLDLL084Z_nag.lib" -o driver.exe
    

    The -mno-cygwin flag removes dependence on cygwin1.dll, using the MinGW version of gcc instead (which is shipped as part of Cygwin). Because both the NAG C Library DLLs and the executables produced by the MinGW gcc compiler use the Microsoft runtime libraries, I/O issues are less likely to occur.

    Substitute CLDLL084Z_mkl.lib to use MKL.

    Tested with gcc version 3.3.3 (cygwin special).

Accessing the Library from Other Environments

The NAG C Library DLLs can also be accessed from many GUI environments. The web pages in the list below contain links to sample projects for Microsoft Visual C++, Borland C++ Builder, Microsoft Visual Basic 6, Microsoft Visual Basic .NET and Borland Delphi, worksheets for Microsoft Excel and some examples showing how to access the NAG C Library from C# and Java applications.

To facilitate calling the NAG C Library DLLs from Visual Basic, "skeleton" files have been produced for each C Library function, providing declare statements, type / structure definitions, constants, enumerated types and skeleton call-back functions (where appropriate). There are two sets of files, one for use with Visual Basic 6 / Visual Basic for Applications code and the other for use with Visual Basic .NET code.

General Advice on Accessing the Library

When running any program linked with the NAG C Library the appropriate DLLs need to be accessible.

The .\bin subfolder of the library folder must be included in your PATH to run applications.

The .\MKL_ia32_8.0\bin subfolder of the library folder must be included in your PATH to run applications linked with MKL. This should appear later in your PATH than the .\bin folder containing the NAG DLLs.

The installation script may have attempted to do this for you, but in some cases manual intervention may be required. On most systems this may be effected using the Environment Variables button on the Control Panel | System | Advanced tab (Advanced System Settings on Windows Vista).

To include functions from the Library in projects developed under an integrated development environment (e.g. Microsoft Developer Studio), the project environment must be set to search for include (.h) files in the .\include subfolder of the library folder. Library files must be searched for under the .\lib subfolder of the library folder. In Developer Studio open the Tools | Options dialog box, select the Projects (or Projects and Solutions) | VC++ Directories section and enter the appropriate setting for each type of folder. In this DLL implementation, for convenience, the MKL symbols are exported directly from the NAG import library CLDLL084Z_mkl.lib, so it is not necessary to specify the MKL import libraries subfolder (.\MKL_ia32_8.0\lib) as well.

If your machine has more than one processor and you are using Intel MKL, then it is recommended that you set the environment variable OMP_NUM_THREADS to the number of available processors, e.g.

  set OMP_NUM_THREADS=2
This will enable the Intel MKL BLAS to make use of the extra processor(s) and will thus speed up the computation of many of the NAG library routines. On most systems setting this environment variable may be effected using the Environment Variables button on the Control Panel | System | Advanced tab (Advanced System Settings on Windows Vista).

Normally you are advised to use NAG_ALLOC to allocate memory and NAG_FREE to deallocate memory, however in mixed language programming, these C preprocessor macros are not available. Instead you may call the x04bjc and x04bdc functions directly to allocate and deallocate memory.

The function x04bjc is the NAG memory allocator in this implementation.

  Pointer NAG_CALL x04bjc(size_t size);

The function x04bdc is the NAG memory deallocator.

  void NAG_CALL x04bdc(Pointer *ptr);

Note: Within a number of NAG C Library functions, memory is allocated internally and returned to the calling function. This allocated memory contains information that is potentially useful to the user. Consequently freeing this memory has been left to user discretion. However, in the context of DLLs such internally allocated memory cannot be freed externally.

For an example of the use of x04bdc, please refer to the g05eac example program.

Note that the NAG C Library DLLs use the __stdcall calling convention for function calls.

Learn more about the NAG DLLs.

© The Numerical Algorithms Group 2008
Privacy Policy | Trademarks

© Numerical Algorithms Group

Visit NAG on the web at:

www.nag.co.uk (Europe and ROW)
www.nag.com (North America)
www.nag-j.co.jp (Japan)

http://www.nag.co.uk/numeric/CL/classocinfo/README.asp